//package com.zegome.game.oanquan.scene.play;
//
//import com.badlogic.gdx.Gdx;
//import com.badlogic.gdx.graphics.g2d.BitmapFont;
//import com.badlogic.gdx.graphics.g2d.TextureAtlas;
//import com.badlogic.gdx.graphics.g2d.TextureRegion;
//import com.badlogic.gdx.scenes.scene2d.Actor;
//import com.badlogic.gdx.scenes.scene2d.Stage;
//import com.badlogic.gdx.scenes.scene2d.ui.Image;
//import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
//import com.badlogic.gdx.scenes.scene2d.ui.Label;
//import com.badlogic.gdx.scenes.scene2d.ui.Skin;
//import com.badlogic.gdx.scenes.scene2d.ui.Table;
//import com.badlogic.gdx.scenes.scene2d.ui.TextField;
//import com.badlogic.gdx.scenes.scene2d.utils.Align;
//import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
//import com.zegome.game.main.ZegomeActivity;
//import com.zegome.game.oanquan.GameCenter;
//import com.zegome.game.oanquan.HighScoreHelper;
//import com.zegome.game.oanquan.ImageAssets;
//import com.zegome.game.util.helper.StageHelper;
//
///**
// * (C) 2013 ZeroTeam
// * @author QuanLT
// */
//
//public class PlayingUI {
//
//	// ===========================================================
//	// Constants
//	// ===========================================================
//	
//	// ===========================================================
//	// Fields
//	// ===========================================================
//	private PlayingScreen mScreen;
//	private Stage mStage;
//	
//	private Table mResultTable;
//	
//	private Image mResultText;
//	private Image mBigBoardImage;
//	private Image mWinBoardImage;
//	private Image mDrawBoardImage;
//	
//	private Image mBlackImage;
//	
//	private ImageButton mMenuButton;
//	private ImageButton mPauseMenuButton;
//	private ImageButton mContinueButton;
//	private ImageButton mExitButton;
//	private ImageButton mSaveScoreButton;
//	
//	private Label[] mWinPlayerLables;
//	private Label[] mLossPlayerLables;
//
//	/*
//	 * highscore board
//	 */
//	private Image mBoardHighScore;
//	private Image mGomeTop;
//	private Image mTopText;
//	private Image[][] mBgNameMarks;
//	private Label[][] mNameMarks;
//
//	/*
//	 * alert dialog board
//	 */
//	private Image mBoardDialog;
//	private ImageButton mOKAlertButton;
//	private ImageButton mCancelAlertButton;
//	private Label mMessageAlert;
//
//	/*
//	 * Board input name
//	 */
//	
//	private Image mBoardInput;
//	private TextField mTextField;
//	private ImageButton mOkInputButton;
//	private ImageButton mCancelInputButton;
//	private Label mInputMessage;
//	
//	// ===========================================================
//	// Constructor
//	// ===========================================================
//	PlayingUI(final PlayingScreen screen) {
//		mScreen = screen;
//		mStage = screen.getStage();
//		
//		init();
//	}
//	
//	void init() {
//		final Skin skin = mScreen.getController().get(GameCenter.ASSET_FOLDER_FONT + GameCenter.ASSET_SKIN, Skin.class);
//		final TextureAtlas popupUi = mScreen.getController().get(ImageAssets.ASSET_FOLDER_ATLAS + ImageAssets.ATLAS_POPUP, TextureAtlas.class);
//		final TextureAtlas gameUi = mScreen.getController().get(ImageAssets.ASSET_FOLDER_ATLAS + ImageAssets.ATLAS_GAME_UI, TextureAtlas.class);
//		final BitmapFont hiFont = mScreen.getController().get(GameCenter.ASSET_FOLDER_FONT + GameCenter.ASSET_FONT_HIGH_SCORE, BitmapFont.class);
//		
//		//input name
//		mBoardInput = StageHelper.createImage(gameUi.findRegion(ImageAssets.REGION_DIAGLOG_IMAGE), 150, 205);
//		mTextField = StageHelper.createTextField(skin, 240, 310, 300, 50);
//		mInputMessage = StageHelper.createLabel(hiFont, "Nhập tên", null, 220, 380);
//		mOkInputButton = StageHelper.createImageButton(skin, gameUi.findRegion(ImageAssets.REGION_DONG_Y), gameUi.findRegion(ImageAssets.REGION_DONG_Y_PRESS), null, 210, 235, 180, 65);
//		mCancelInputButton = StageHelper.createImageButton(skin, gameUi.findRegion(ImageAssets.REGION_HUY), gameUi.findRegion(ImageAssets.REGION_HUY_PRESS), null, 415, 235, 180, 65);
//		
//		mOkInputButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				// TODO Auto-generated method stub
//				final String text = new String(mTextField.getText());
//				final ZegomeActivity activity = mScreen.getController().getActivity();
//				if (text.trim().equals("")) {
//					activity.onShowToast("Hãy nhập tên", ZegomeActivity.LONG_SHOW);
//					return;
//				}
//				activity.onShowToast(mScreen.getHighScoreIndex() + " | " + mScreen.getScore(), ZegomeActivity.LONG_SHOW);
//				HighScoreHelper.savaHighScore(activity, mTextField.getText(), mScreen.getScore(), mScreen.getHighScoreIndex());
//				hideInputName();
//				resetHighScoreBoard();
//				showHighScoreBoard();
////				mScreen.backMenuScreen();
//			}
//		});
//		mCancelInputButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				// TODO Auto-generated method stub
//				hideInputName();
//				mScreen.backMenuScreen();
//			}
//		});
//		
//		//dialog message
//		mBoardDialog = StageHelper.createImage(gameUi.findRegion(ImageAssets.REGION_DIAGLOG_IMAGE), 150, 205);
//		mMessageAlert = StageHelper.createLabel(hiFont, "", null, 205, 352);
//		mOKAlertButton = StageHelper.createImageButton(skin, gameUi.findRegion(ImageAssets.REGION_DONG_Y), gameUi.findRegion(ImageAssets.REGION_DONG_Y_PRESS), null, 210, 230, 180, 65);
//		mCancelAlertButton = StageHelper.createImageButton(skin, gameUi.findRegion(ImageAssets.REGION_HUY), gameUi.findRegion(ImageAssets.REGION_HUY_PRESS), null, 415, 230, 180, 65);
//		
//		mOKAlertButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				// TODO Auto-generated method stub
//				hideResult();
//				hideDialogMessage();
//				showInputName();
//			}
//		});
//		mCancelAlertButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				hideDialogMessage();
//				mScreen.backMenuScreen();
//			}
//		});
//		
//		//highscore
//		mBoardHighScore = StageHelper.createImage(popupUi.findRegion(ImageAssets.REGION_POPUP_BOARD), 140, 0, 504, 480);
//		mGomeTop = StageHelper.createImage(gameUi.findRegion(ImageAssets.REGION_TOP_GOME), 170, 375);
//		mTopText = StageHelper.createImage(gameUi.findRegion(ImageAssets.REGION_TOP_TEXT), 275, 390);
//		mBgNameMarks = new Image[5][2];
//		mNameMarks = new Label[5][2];
//
//		for (int i = 0; i < 5; i ++) {
//			final int dis = 72 * i;
//			
//			mBgNameMarks[i][0] = StageHelper.createImage(gameUi.findRegion(ImageAssets.REGION_HI_BT), 189, 316 - dis, 270, 60);
//			mBgNameMarks[i][1] = StageHelper.createImage(gameUi.findRegion(ImageAssets.REGION_HI_BT_PRESS), 461, 316 - dis, 140, 60);
//			
//			mNameMarks[i][0] = StageHelper.createLabel(hiFont, "Tran Thi Hang", null, 220, 336 - dis);
//			mNameMarks[i][1] = StageHelper.createLabel(hiFont, "10000", null, 480, 336 - dis);
//		}
//		
//		final TextureRegion resultRegion = gameUi.findRegion(ImageAssets.REGION_RESULT_TEXT);
//		mResultText = StageHelper.createImage(resultRegion, 300, 340);
//		final TextureRegion boardRegion = popupUi.findRegion(ImageAssets.REGION_POPUP_BOARD);
//		mBigBoardImage = StageHelper.createImage(boardRegion, 190, 40);
//		final TextureRegion winBoardRegion = gameUi.findRegion(ImageAssets.REGION_WIN_BOARD);
//		mWinBoardImage = StageHelper.createImage(winBoardRegion, 260, 220);
//		final TextureRegion drawBoardRegion = gameUi.findRegion(ImageAssets.REGION_DRAW_BOARD);
//		mDrawBoardImage = StageHelper.createImage(drawBoardRegion, 260, 220);
//
//		final TextureRegion menuRegion = gameUi.findRegion(ImageAssets.BUTTON_MENU);
//		final TextureRegion menuRegionPress = gameUi.findRegion(ImageAssets.BUTTON_MENU_PRESS);
//		mMenuButton = StageHelper.createImageButton(skin, menuRegion, menuRegionPress, null, 305, 140);
//		mMenuButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				onMenuButtonClick();
//			}
//		});
//
//		mPauseMenuButton = StageHelper.createImageButton(skin, menuRegion, menuRegionPress, null, 305, 295);
//		mPauseMenuButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				onPauseMenuButtonClick();
//			}
//		});
//		
//		final TextureRegion continueRegion = gameUi.findRegion(ImageAssets.BUTTON_CONTINUE);
//		final TextureRegion continueRegionPress = gameUi.findRegion(ImageAssets.BUTTON_CONTINUE_PRESS);
//		mContinueButton = StageHelper.createImageButton(skin, continueRegion, continueRegionPress, null, 305, 200);
//		mContinueButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				onContinueButtonClick();
//			}
//		});
//
//		final TextureRegion exitRegion = gameUi.findRegion(ImageAssets.BUTTON_EXIT);
//		final TextureRegion exitRegionPress = gameUi.findRegion(ImageAssets.BUTTON_EXIT_PRESS);
//		mExitButton = StageHelper.createImageButton(skin, exitRegion, exitRegionPress, null, 305, 120);
//		mExitButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				onExitButtonClick();
//			}
//		});
//
//		final TextureRegion saveRegion = gameUi.findRegion(ImageAssets.BUTTON_SAVE_SCORE);
//		final TextureRegion saveRegionPress = gameUi.findRegion(ImageAssets.BUTTON_SAVE_SCORE_PRESS);
//		mSaveScoreButton = StageHelper.createImageButton(skin, saveRegion, saveRegionPress, null, 305, 70);
//		mSaveScoreButton.addListener(new ChangeListener() {
//			
//			@Override
//			public void changed(ChangeEvent arg0, Actor arg1) {
//				onSaveScoreClick();
//			}
//		});
//		
//		mBlackImage = StageHelper.createImage(mScreen.getController().getBlackRegion(), 0, 0, 800, 480);
//		mBlackImage.setColor(0, 0, 0, 0.7f);
//		
//		final int h = 60;
//		final int w1 = 200;
//		final int w2 = 90;
//		mResultTable = StageHelper.createTable(skin, 260, 225, 290, 120);
//		mWinPlayerLables = new Label[2];
//		mLossPlayerLables = new Label[2];
//		
//		mWinPlayerLables[0] = new Label("You", skin);
//		mWinPlayerLables[0].setBounds(0, 0, w1, h);
//		mWinPlayerLables[0].setAlignment(Align.center|Align.bottom);
//		mWinPlayerLables[0].setWrap(true);
//
//		mWinPlayerLables[1] = new Label("", skin);
//		mWinPlayerLables[1].setBounds(0, 0, w2, h);
//		mWinPlayerLables[1].setAlignment(Align.left|Align.bottom);
//		mWinPlayerLables[1].setWrap(true);
//		
//		
//		mLossPlayerLables[0] = new Label("Computer", skin);
//		mLossPlayerLables[0].setBounds(0, 0, w1, h);
//		mLossPlayerLables[0].setAlignment(Align.center|Align.bottom);
//		mLossPlayerLables[0].setWrap(true);
//
//		mLossPlayerLables[1] = new Label("", skin);
//		mLossPlayerLables[1].setBounds(0, 0, w2, h);
//		mLossPlayerLables[1].setAlignment(Align.left|Align.bottom);
//		mLossPlayerLables[1].setWrap(true);
//		
//		mResultTable.defaults().pad(2);
//		
//		mResultTable.row().height(h);
//		mResultTable.add(mWinPlayerLables[0]).width(w1);
//		mResultTable.add(mWinPlayerLables[1]).width(w2);
//		mResultTable.row().height(h);
//		mResultTable.add(mLossPlayerLables[0]).width(w1);
//		mResultTable.add(mLossPlayerLables[1]).width(w2);
//		
//	}
//	
//	// ===========================================================
//	// Getter & Setter
//	// ===========================================================
//
//	// ===========================================================
//	// Methods for/from SuperClass/Interfaces
//	// ===========================================================
//
//	// ===========================================================
//	// Methods
//	// ===========================================================
//
//	private void onPauseMenuButtonClick() {
//		mScreen.backMenuScreen();
//	}
//	
//	private void onMenuButtonClick() {
//		if (GameCenter.isNeedAI && mScreen.getHighScoreIndex() > -1) {
//			hideResult();
//			showDialogMessage();
//		} else {
//			mScreen.backMenuScreen();
//		}
//	}
//	
//	private void onContinueButtonClick() {
//		mScreen.mState = PlayingScreen.PLAYING;
//		hidePause();
//		mScreen.setup(true, true);
//	}
//	
//	public void clear() {
//		mBigBoardImage.remove();
//		mContinueButton.remove();
//		mBlackImage.remove();
//		mExitButton.remove();
//		mPauseMenuButton.remove();
//		mMenuButton.remove();
//		mSaveScoreButton.remove();
//		mResultTable.remove();
//		mWinBoardImage.remove();
//		mResultText.remove();
//	}
//	
//	private void onExitButtonClick() {
//		Gdx.app.exit();
//	}
//	
//	private void onSaveScoreClick() {
//		hideResult();
//		showInputName();
//	}
//	
//	public void showInputName() {
//		mScreen.mState = PlayingScreen.SAVE_SCORE;
//		
//		mStage.addActor(mBlackImage);
//		mStage.addActor(mBoardInput);
//		mStage.addActor(mTextField);
//		mStage.addActor(mOkInputButton);
//		mStage.addActor(mCancelInputButton);
//		mStage.addActor(mInputMessage);
//		mScreen.getController().getInputText().addTextField(mTextField, true);
//	}
//	
//	public void hideInputName() {
//		mBlackImage.remove();
//		mCancelInputButton.remove();
//		mBoardInput.remove();
//		mTextField.setText("");
//		mTextField.remove();
//		mInputMessage.remove();
//		mOkInputButton.remove();
//	}
//	
//	public void showDialogMessage() {
//		mScreen.mState = PlayingScreen.SHOW_HIGH_SCORE;
//		mStage.addActor(mBlackImage);
//		final String mess = "Bạn ghi được " + mScreen.getScore() +" điểm\n" + "xếp thứ " 
//							+ MESSAGE_REQUEST_HIGH_SCORE[mScreen.getHighScoreIndex()]
//							+ " tốp đại cao thủ.\nBạn có muốn ghi danh không?";
//		mMessageAlert.setText(mess);
//		
//		mStage.addActor(mBoardDialog);
//		mStage.addActor(mMessageAlert);
//		mStage.addActor(mOKAlertButton);
//		mStage.addActor(mCancelAlertButton);
//	}
//	private static final String[] MESSAGE_REQUEST_HIGH_SCORE = {"nhất", "hai", "ba", "tư", "năm"};
//	public void hideDialogMessage() {
//		mBlackImage.remove();
//		mBoardDialog.remove();
//		mMessageAlert.remove();
//		mOKAlertButton.remove();
//		mCancelAlertButton.remove();
//	}
//	
//	private void resetHighScoreBoard() {
//		final String[] names = HighScoreHelper.getNameArray(mScreen.getController().getActivity());
//		final int[] scores = HighScoreHelper.getScoreArray(mScreen.getController().getActivity());
//		
//		for (int i = 0; i < 5; i++) {
//			mNameMarks[i][0].setText(names[i]);
//			mNameMarks[i][1].setText(String.valueOf(scores[i]));
//		}
//	}
//	
//	public void showHighScoreBoard() {
//		mScreen.mState = PlayingScreen.SHOW_HIGH_SCORE;
//		mStage.addActor(mBlackImage);
//		mStage.addActor(mBoardHighScore);
//		for (int i = 0; i < 5; i++) {
//			mStage.addActor(mBgNameMarks[i][0]);
//			mStage.addActor(mBgNameMarks[i][1]);
//			mStage.addActor(mNameMarks[i][0]);
//			mStage.addActor(mNameMarks[i][1]);
//		}
//		mStage.addActor(mTopText);
//		mStage.addActor(mGomeTop);
//	}
//	
//	public void hideHighScoreBoard() {
//		mBlackImage.remove();
//		mBoardHighScore.remove();
//		mGomeTop.remove();
//		mTopText.remove();
//		for (int i = 0; i < 5; i++) {
//			mBgNameMarks[i][0].remove();
//			mBgNameMarks[i][1].remove();
//			mNameMarks[i][0].remove();
//			mNameMarks[i][1].remove();
//		}
//	}
//	
//	public void showPause() {
//		mStage.addActor(mBlackImage);
//		mStage.addActor(mBigBoardImage);
//		mStage.addActor(mContinueButton);
//		mStage.addActor(mPauseMenuButton);
//		mStage.addActor(mExitButton);
//	}
//	
//	public void hidePause() {
//		mBlackImage.remove();
//		mBigBoardImage.remove();
//		mContinueButton.remove();
//		mPauseMenuButton.remove();
//		mExitButton.remove();
//	}
//	
//	public void hideResult() {
//		mBlackImage.remove();
//		mBigBoardImage.remove();
//		mResultText.remove();
//		mDrawBoardImage.remove();
//		mWinBoardImage.remove();
//		mWinPlayerLables[0].remove();
//		mWinPlayerLables[1].remove();
//		mLossPlayerLables[0].remove();
//		mLossPlayerLables[1].remove();
//		mMenuButton.remove();
//		mSaveScoreButton.remove();
//		mResultTable.remove();
//	}
//	
//	public void showResult(final byte winner, final int firstScore, final int secondScore) {
//		result(winner, firstScore, secondScore);
//	}
//	
//	private void result(final int winner, final int firstScore, final int secondScore) {
//		mStage.addActor(mBlackImage);
//		mStage.addActor(mBigBoardImage);
//		mStage.addActor(mResultText);
//		
//		if (!GameCenter.isNeedAI) {
//			if (winner == PlayingScreen.DRAW) {
//				mStage.addActor(mDrawBoardImage);
//				mWinPlayerLables[0].setText("Player 1");
//				mWinPlayerLables[1].setText(String.valueOf(firstScore));
//				mLossPlayerLables[0].setText("Player 2");
//				mLossPlayerLables[1].setText(String.valueOf(secondScore));
//			} else {
//				mStage.addActor(mWinBoardImage);
//				mWinPlayerLables[0].setText("Player 1");
//				mWinPlayerLables[1].setText(String.valueOf(firstScore));
//				mLossPlayerLables[0].setText("Player 2");
//				mLossPlayerLables[1].setText(String.valueOf(secondScore));
//			} 
//		} else {
//			if (winner == PlayingScreen.DRAW) {
//				mStage.addActor(mDrawBoardImage);
//				mWinPlayerLables[0].setText("Player 1");
//				mWinPlayerLables[1].setText(String.valueOf(firstScore));
//				mLossPlayerLables[0].setText("Player 2");
//				mLossPlayerLables[1].setText(String.valueOf(secondScore));
//			}
//			else if (winner == PlayingScreen.FIRST_PLAYER) {
//				mStage.addActor(mWinBoardImage);
//				mWinPlayerLables[0].setText("You");
//				mWinPlayerLables[1].setText(String.valueOf(firstScore));
//				mLossPlayerLables[0].setText("Computer");
//				mLossPlayerLables[1].setText(String.valueOf(secondScore));
//			} else {
//				mStage.addActor(mWinBoardImage);
//				mWinPlayerLables[0].setText("Computer");
//				mWinPlayerLables[1].setText(String.valueOf(secondScore));
//				mLossPlayerLables[0].setText("You");
//				mLossPlayerLables[1].setText(String.valueOf(firstScore));
//			}
//		}
//		mStage.addActor(mMenuButton);
//		mStage.addActor(mSaveScoreButton);
//		mStage.addActor(mResultTable);
//	}
//	
//	// ===========================================================
//	// Inner and Anonymous Classes
//	// ===========================================================
//}
